﻿using System.Threading.Tasks;

namespace StoCombatLogHUD.Toolkit.ExtensionMethods
{
	/// <summary>
	/// Usefull extensions for Task.
	/// </summary>
	public static class TaskExtensions
	{
		/// <summary>
		/// Determines whether the specified task is running.
		/// </summary>
		/// <param name="task">The task.</param>
		/// <returns>
		///   <c>true</c> if the specified task is running; otherwise, <c>false</c>.
		/// </returns>
		public static bool IsRunning(this Task task)
		{
			return (task != null && !task.IsCompleted && !task.IsCanceled && !task.IsFaulted);
		}
	}
}
